package edu.hawaii.ics414;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

/**
 * Initializes the screen that contains the search box for searching for a game.
 * 
 * @author Matthew Mizumoto
 * 
 */

public class SearchView extends Activity {

  /*
   * Called when the activity is first created.
   */
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_view);
    Button searchButton = (Button) findViewById(R.id.searchButton);
    searchButton.setOnClickListener(new OnClickListener() {
      @Override
      /*
       * Initializes the button for searching for a search term. (non-Javadoc)
       * 
       * @see android.view.View.OnClickListener#onClick(android.view.View)
       */
      public void onClick(View v) {
        EditText searchTerm = (EditText) findViewById(R.id.searchText);
        String toSearch = searchTerm.getText().toString().trim();
        Intent myIntent = new Intent(v.getContext(), SearchResults.class);
        myIntent.putExtra("gameName", toSearch);
        startActivityForResult(myIntent, 0);
      }
    });
  }
}
